<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>发送短信</title>
  <script>

    function check() {
      var m = document.getElementById("mobiles").value;
      var c = document.getElementById("content").value;
      //验证是否为空
      if (m == "" || c == "") {
        alert("手机号码或者内容不能为空。");
        return false;
      }
      //过滤最后一个为","的字符
      var str = m.substring(m.length - 1, m.length);
      if (str == ",") {
        m = m.substring(0, m.length - 1);
      }
      //判断长度是否超过20个
      var m_array = m.split(",");
      if (m_array.length > 20) {
        alert("每次最多只能发送20个。");
        return false;
      }
      for (i = 0; i < m_array.length; i++) {
        //验证手机号码是否正确
        if (!ckMobile(m_array[i])) {
          alert(m_array[i] + "的手机号码不正确，请检查。");
          //如果手机号码不正确则选中错误的手机号码
          var s = document.getElementById("mobiles").createTextRange();
          if (s.findText(m_array[i]))
          {
            s.select();
            s.collapse(false);
          }
          return false;
        }
      }

      return true;

    }
    function ckMobile(m) {
      if (m.length > 11) {
        return false;
      } else {
        var t = /^(13\d{9})|(15\d{9})|(18\d{9})|(0\d{10,11})$/;
        return t.test(m);
      }
    }


  </script>
  <style type="text/css">
  <!--
  body {
    font-size: 12px;
    font-family: Arial, "宋体";
  }

  a {
    text-decoration: none;
    color: #000;
  }

  a:hover {
    color: #900;
    text-decoration: underline;
  }

  .text1 {
    font-weight: bold;
    font-size: 14px;
    color: #900;
  }

  .input1 {
    width: 400px;
  }

  textarea {
    width: 400px;
  }

  .red {
    color: #F00;
  }

  -->
  </style>
</head>

<body>
<g:form action="sendsave" method="post" onSubmit="return check();">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="10" rowspan="4">&nbsp;</td>
              <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="40" colspan="2" valign="bottom" bgcolor="#FFFFF4"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="100" height="30" align="center" class="text1"><a href="/sms/send">发短信</a></td>
                      <td width="100" height="30" align="center" class="text1"><a href="/smsRecord/list">短信记录</a></td>
                      <td width="100" height="30" align="center" class="text1"><a href="/sms/pressure">短信充值</a></td>
                      <td>&nbsp;</td>
                    </tr>
                  </table></td>
                </tr>
                <tr>
                  <td width="80" height="50">接收手机：</td>
                  <td align="left" class="red"><textarea name="mobiles" rows="5" id="mobiles" class="input1"/></textarea>
                    多个手机号码用“,”号分割，最多支持20个手机号码，要同时发送更多功能，请<a href="http://www.b2m.cn" target="_blank">点击登陆完整版</a>。</td>
                </tr>
              </table></td>
              <td width="10" rowspan="4">&nbsp;</td>
            </tr>
            <tr>
              <td height="10">&nbsp;</td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="80" valign="top">短信内容：</td>
                  <td><label>
                    <textarea name="content" id="content" rows="5"></textarea>
                  </label></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="left" class="red">${flash.message}<input type="submit" name="button" id="button" value="确认并发送"/></td>
                </tr>
              </table></td>
              <td>&nbsp;</td>
            </tr>

          </table></td>

        </tr>
      </table></td>
    </tr>
  </table>
</g:form>
</body>
</html>
